﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

using agvcontroller.Common.DataBase;
using agvcontroller.Log;

namespace agvcontroller.Common
{
    public class CActionType
    {
        List<string> _ActionTypeList = new List<string>();
        public List<string> ActionTypeList
        {
            get { return _ActionTypeList; }
        }

        CAGVCDB AGVCDB;

        Logger Log;

        public CActionType()
        {
            Log = new Logger("ActionType");

            AGVCDB = CAGVCDB.getInstance();

            GetDataFromDB();
        }

        int GetDataFromDB()
        {
            DataTable table = AGVCDB.AGVCDataSet.Tables["ActionType"];

            try
            {
                _ActionTypeList.Clear();

                foreach (DataRow row in table.Rows)
                {
                    _ActionTypeList.Add(Convert.ToString(row["Type"]));
                }

                if (_ActionTypeList.Count == 0)
                {
                    Log.Info(string.Format("Action List item is empty"));
                }
            }
            catch (Exception ex)
            {
                Log.Exception(string.Format("{0},{1}", ex.Message, ex.StackTrace));
                return CReturnCode.ERR_DATA_ACQUIRING_FAIL;
            }

            return CReturnCode.SUCCESS;
        }
    }
}
